<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<title>女神</title>
<link rel="stylesheet" href="static/css/reset.css">
<link rel="stylesheet" href="static/css/css.css">
<script src="static/js/jquery-1.9.1.js"></script>
<script src="static/js/js.js"></script>
<script src="http://yaotv.qq.com/shake_tv/include/js/jsapi.js"></script>
<script type="text/javascript">
	//时间判断
	
	var api_url = "http://nsxz.beibeixy.com";
	
	var thePeriods, curPeriods;
	function initPeriods() {
		$.getJSON(api_url+"/periods_jsonp?jsoncallback=?",{},
			function(data){
				alert(data+" 1133  "+data.pcnt);
				/*
				$.each(data, function (i, n) {
					alert(i+" "+n+" "+n.section);
					if(n.section == 'ALL') thePeriods = n;
					if(n.state == 1) curPeriods = n;
				});
				alert("期数总控："+thePeriods+" 当前播出："+curPeriods);
				*/
		}); 
	}
	
	//$.get('http://skulaoo.eicp.net/card/set', {ucId:'sss'});
	
	initPeriods();
	
	var unionid = "";
 	//如果在摇电视平台以素材方式进入本页面时：
	shaketv.authorize("wxb557dba0c04e45e6","userinfo",function(d){
		if(2>1) return;
		//alert(d.errorCode + ":"+d.errorMsg + " code:"+d.code);
    	//获得code之后，因secretkey在js中使用会有泄露的风险，所以请通过后台接口获取token、解密code
		$.getJSON("http://skulaoo.eicp.net/user/get_jsonp?jsoncallback=?",{code:'abc'},//正式环境需改为{code:d.code}
			function(json){
				if(json.unionid) {
					//alert(json.unionid);
					unionid = json.unionid;
					$("#test1").show();
				} else $("#test1").hide();
		}); 
	});
	var cnt = 0;
	$(document).ready(function(){
		//alert('into dom\n'+'${openId!}');		
		$("#test1").click(function(){
			if(cnt++>0) return;
			//_czc.push(﻿["_trackEvent","首页,"抢点击",,,"test1"]);
			$.getJSON('http://skulaoo.eicp.net/card/get_jsonp?jsoncallback=?', {unionid:unionid}, function(result){
				//window.frames["ifrtp"].location.reload();//统计计数
				cnt = 0;
				if(result.code == '-1') {
					alert("没抢到");
				} else {
					alert("抢到啦,"+result.data.ctype);
					if(2>1) return;
					if(result.data.ctype == '01') {
						var cardObj = result.data.cards;
						var card = {cardId:cardObj.cardId, cardExt:'{"nonce_str":"'+cardObj.nonceStr+'","timestamp":"'+cardObj.timestamp+'","signature":"'+cardObj.cardSignature+'"}'};
						wx.addCard({
						 cardList: [card],
						 success: function (res) {
						   //alert('已添加卡券：' + JSON.stringify(res.cardList));
						   //var cardList = res.cardList; // 添加的卡券列表信息
						   $.get('/card/set', {ucId:result.data.ucId});
						 }
					 });
					} else if(result.data.ctype == '02') {
						window.location.href = result.data.getUrl; 
					} else if(result.data.ctype == '03') {
						window.location.href = '/gift?unionid='+unionid;
					} else if(result.data.ctype == '04') {
						window.location.href = '/gift?unionid='+unionid;
					}
				}
			});
		});
	});
</script>
</head>
<body>
<div class="page" style="background:#fff url(static/images/bg3.jpg) no-repeat; background-size:100% auto;">
	<div class="content" style="padding:0 0 49px 0;">
		<h1 class="headline">《女神新装》百万红包</h1>
		<img src="static/images/logo.png" class="logo3">
		<div class="win">
			<img src="static/images/icon_bao.png" class="pic">
			<div class="title">获得潘婷现金<br>20元</div>
			<div class="desc">已存入零钱，可直接提现</div>
		</div>
		
		<div class="win_list">
			<div class="top">10个红包，14秒被抢光</div>
			<ul>
				<li>
					<div><input id="test1" type="button" value="抢卡卷"/></div>
				</li>
				 
			</ul>
		</div>
	</div>
	<div class="footer">
		<div class="nav">
			<a href="index.html"><img src="static/images/nav_home.png"></a>
			<a href="#"><img src="static/images/nav_lm.png"></a>
			<a href="my_gift.html"><img src="static/images/nav_gift.png"></a>
		</div>
	</div>
</div>
</body>
</html>